import { FormSchema } from '@/components/Form';
import { useI18n } from '@/hooks/web/useI18n';

const { t } = useI18n();

export const editData: FormSchema[] = [
  {
    field: 'maintain',
    component: 'RadioGroup',
    label: '维护操作',
    required: true,
    defaultValue: 1,
    colProps: {
      span: 20,
    },
    componentProps: {
      options: [
        { label: '开放', value: 1 },
        { label: '维护', value: 2 },
      ],
    },
  },
  {
    field: 'maintain_start_time',
    component: 'DatePicker',
    required: true,
    label: '开始时间',
    slot: 'startTime',
    //labelWidth: '150px',
    colProps: {
      span: 20,
    },
    ifShow: (record) => (String(record.values.maintain) === '2' ? true : false),
  },
  {
    field: 'maintain_end_time',
    component: 'DatePicker',
    required: true,
    label: '结束时间',
    slot: 'endTime',
    //labelWidth: '150px',
    colProps: {
      span: 20,
    },
    ifShow: (record) => (String(record.values.maintain) === '2' ? true : false),
  },
  {
    field: 'notice',
    component: 'Input',
    label: '维护说明',
    //required: true,
    // defaultValue: false,
    colProps: {
      span: 20,
    },
    rules: [
      {
        required: true,
        validator: (value) => { 
          if (!value) {
            return Promise.resolve();
          }
        }
      },
    ],
    slot: 'notice',
    ifShow: (record) => (String(record.values.maintain) === '2' ? true : false),
  },
];
